using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Modules.Abstracts;
using FiltronASP.Models.DAO.Interfaces;
using System.Web.UI.WebControls;
using FiltronASP.Models;
using FiltronASP.Helpers.CatalogueMenu;
using FiltronASP.Helpers.Translations;


namespace FiltronASP.Modules
{
    public class hdmachineCarsSearchModule : AbstractModule
    {
        private Page currentPage;

        /// <summary>
        /// Klasa odpowiedzialna za generowanie contentu przez modul.
        /// </summary>
        /// <param name="page">biezaca strona</param>
        /// <returns>content</returns>
        public override string GenerateContent(FiltronASP.Models.Page page)
        {
            this.currentPage = page;
            int pageId = page.page_id;
            int languageId = Convert.ToInt32(page.language_id);
            return this.generateBottomMenu(languageId, pageId) + this.generateInnerContent(languageId);
        }

        private string generateBottomMenu(int languageId, int pageId) 
        {
            string htmlToReturn = "";
            htmlToReturn += "<div id=\"bottomMenu\">";
            htmlToReturn += "   <div class=\"selectMarketMenu\">";
            htmlToReturn += "       <span class=\"changeMarketInfo\">" + translationHelper.getTranslation("_currentMarketInfoWIX", languageId) + "</span>";
            htmlToReturn += "       <a href=\"" + translationHelper.getTranslation("_changeMarketLink", languageId) + "\" class=\"changeMarketButton\">Zmień</a>";
            htmlToReturn += "   </div>";
            htmlToReturn += "   <ul class=\"selectCarTypeMenu\">";

            htmlToReturn += CatalogueMenuHelper.generateMenuWIX(languageId, pageId);

            htmlToReturn += "   </ul>"; //</selectCarTypeMenu>
            htmlToReturn += "<div id=\"selectCarTypeMenuUnder\">";
            htmlToReturn += "<div class=\"selectCarTypeMenuUnderSingle\" id=\"passengerCarSelectBrand\">";
            htmlToReturn += "<label for=\"\">" + translationHelper.getTranslation("_catBrand", languageId) + "</label>";
            htmlToReturn += "<select onchange=\"doWork('id_master', 'id_detail', '" + Helpers.XmlHelper.XMLHelper.getLanguageNameById(Convert.ToInt32(this.currentPage.language_id)) + "')\" id=\"id_master\" name=\"brand\">";
            htmlToReturn += "<option value=\"\" selected=\"selected\">" + translationHelper.getTranslation("_selectManufacturer", languageId) + "</option>";
            Models.DAO.WIX.WixMakeDAO Brand = new FiltronASP.Models.DAO.WIX.WixMakeDAO();
            IQueryable<WixMake> wixMakes = Brand.FindByVehicle(6);
            if (wixMakes != null)
            {
                foreach (var item in wixMakes) {
                    htmlToReturn += String.Format("<option value=\"{0}\"> {1} </option>", item.make_id, item.make_name);
                }
            }   //if            
            htmlToReturn += "</select>";
            htmlToReturn += "</div>";
            htmlToReturn += "<div class=\"selectCarTypeMenuUnderSingle\" id=\"passengerCarSelectType\">";
            htmlToReturn += "<label for=\"\">" + translationHelper.getTranslation("_catType", languageId) + "</label>";
            htmlToReturn += "<select onchange=\"doEngineWork('searchLeftSide', 'id_detail', '" + Helpers.XmlHelper.XMLHelper.getLanguageNameById(Convert.ToInt32(this.currentPage.language_id)) + "')\" name=\"brand\" id=\"id_detail\">";
            htmlToReturn += "</select>";
            htmlToReturn += "</div>";
            htmlToReturn += CatalogueMenuHelper.GenerateLastModifiedWix(this.currentPage.language_id);
            htmlToReturn += "</div>"; //</selectCarTypeMenuUnder>
            htmlToReturn += "</div>"; //</bottomMenu>            
            return htmlToReturn;
        }

        private string generateInnerContent(int languageId) {
            string htmlToReturn = "";
            htmlToReturn += " <div id=\"contentHolderInner\">";
            htmlToReturn += " <div id=\"ajaxStatementInfo\">" + translationHelper.getTranslation("_ajaxSelectBrand", languageId) + "</div>";
            htmlToReturn += this.generateEnginePart();
            return htmlToReturn;
        }

        private string generateEnginePart() {
            string htmlToReturn = "";
            htmlToReturn += "<div id=\"searchLeftSide\"></div>";
            htmlToReturn += "<div id=\"searchRightSide\">";
            htmlToReturn += "   <div class=\"searchRightSideTop\"></div>";
            htmlToReturn += "   <div id=\"searchRightSideBottom\"></div>";
            htmlToReturn += "</div>";
            htmlToReturn += "</div> <!-- #contentHolderInner -->"; // #contentHolderInner
            return htmlToReturn;
        }

        

    }
}
